﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MobileAPI.DAL;
using MobileAPI.Entity.Model;

namespace MobileAPI.BLL
{
    public class BLLRepairsInfo:BaseBLL
    {

        private DALRepairsInfo dalRepair;
        public DALRepairsInfo DALRepair
        {
            get
            {
                if (dalRepair == null)
                {
                    dalRepair = DALFactory.getInstance().CreateRepairsInfoDAL();
                }
                return dalRepair;
            }
        }
        /// <summary>
        /// 保修详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ERepairsInfo GetRepairDetails(string RepairsId,string RepairsDate)
        {
            try
            {
                return DALRepair.GetRepairDetails(RepairsId, RepairsDate);
            }
            catch (Exception e)
            {

                base.WriteLog(e.Message);
                throw e;
            }
        }
        /// <summary>
        /// 今日保修列表
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public IList<ERepairsInfo> GetTodayRepairsList(string userName)
        {
            try
            {
                return DALRepair.GetTodayRepairsList(userName);
            }
            catch (Exception e)
            {

                base.WriteLog(e.Message);
                throw e;
            }
        }

        
        public IList<ERepairsInfo> SearchTodayRepairsList(string UserName,string CustomerName, string RepairsID, string StartDate, string EndDate, string Progress)
        {
            try
            {
                return DALRepair.SearchTodayRepairsList(UserName,CustomerName,RepairsID,StartDate,EndDate,Progress);
            }
            catch (Exception e)
            {

                base.WriteLog(e.Message);
                throw e;
            }
        }

        /// <summary>
        /// 新增一条新保修
        /// </summary>
        /// <param name="repair"></param>
        /// <returns></returns>
        public bool InsertRepairs(ERepairsInfo repair,string UserName)
        {
            try
            {
                return DALRepair.InsertRepairs(repair,UserName);
            }
            catch (Exception e)
            {

                base.WriteLog(e.Message);
                throw e;
            }
        }

    }
}
